<?

if (null==$listfield1) $listfield1 = "code";
if (null==$listfield2) $listfield2 = "firstname";
if (null==$listfield3) $listfield3 = "lastname";
if (null==$listfield4) $listfield4 = "tel";
if (null==$listfield5) $listfield5 = "email";

if ($action=="search"){

	$Query = "select id, $listfield1, $listfield2, $listfield3, $listfield4, $listfield5 from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like '%$Search%'   order by id desc Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table WHERE $listfield1 Like '%$Search%' OR $listfield2 Like  '%$Search%'";

}else{

	$Query = "select id, $listfield1, $listfield2, $listfield3, $listfield4, $listfield5 from $table order by $listfield2 Limit $Offset, $ListNum";

	$Query1 = "select count(*) as total from $table";
	
}

$list = myQuery($Query);


$CountRecord = myQuery($Query1);

$CountNum = $CountRecord[0][0];
$Url="&Searcn=$Search&action=$action";	


print(splitPage($Url,$CountNum));

?>


        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="tb">
          <tr class="tbheader"> 
            <td width="20%"><?print(ucfirst($listfield1))?></td>
            <td width="20%">Customer Name</td>
			<td width="20%">Tel</td>
			<td width="20%">Email</td>
			<td width="20%"></td>
          </tr>


<?
if ($list){
	for ($i=0;$i<count($list);$i++){?>
          <tr class="tbcontent1"> 
            <td><?print($list[$i][1])?></td>
            <td align="center"><?print($list[$i][2])?> <?print($list[$i][3])?></td>
			<td align="center"><?=$list[$i][4]?></td>
			<td align="center"><a href="mailto:<?=$list[$i][5]?>"><?=$list[$i][5]?></a></td>
			<td align=center bgcolor="ECECEC">
			<a href="edit.php?Start_Num=<?echo $Start_Num?>&id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_edit.gif" border="0" alt="Edit"></a>
			<a href="delete.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_delete.gif" border="0" Alt="Delete"></a>
			<a href="enquire.php?id=<?print($list[$i][0])?>"><img src="<?print($rela_path)?>images/bt_enquiry.gif" border="0" Alt="Enquire"></a></td>
          </tr>
<?
	}	
}?>


        </table>

<?print(splitPage($Url,$CountNum))?>
